import com.google.appengine.api.datastore.Entity
import groovyx.gaelyk.datastore.*
import com.google.appengine.api.datastore.Entity

import com.google.appengine.api.datastore.*
import static com.google.appengine.api.datastore.FetchOptions.Builder.*

def author1 = new Entity("Author")
author1.name = "Laurie"
author1.fav=["tut", "om", "sat"]
author1.save()

def b1 = new Entity("Book")
b1.title = "Book1"
b1.authors = [author1.key]
b1.save()

author1.books = [ b1.key ]
author1.save()

def book = datastore.get(b1.key)
def chrisAuthors = book.authors.findAll { authorKey -> datastore.get(authorKey).name == 'Chris' }
//assert chrisAuthors.size() == 1
print chrisAuthors
def ak = author1.key
log.info ("hello" + ak)
def au = datastore.get(ak)
print au.fav[1]
